<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>图片裁剪</title>
    <link rel="stylesheet" href="./style.css" />
    <script src="./script.js"></script>
  </head>

  <body>
    <div class="card">
      <h1>图片实时裁剪</h1>
      <p class="description">选择图片后，在左侧拖动选框进行裁剪</p>

      <!-- 这里主要涉及对文件的处理 -->
      <div class="main-controls">
        <label for="file" class="btn upload-btn">选择图片</label>
        <input type="file" id="file" accept="image/*" />
        <button id="output" class="btn output-btn">下载裁剪图</button>
      </div>

      <div id="workspace" class="workspace hidden">
        <div class="preview-container">
          <h4>原图与裁剪框</h4>
          <div class="pre-view">
            <img id="preview" />
            <div id="crop-box">
              <div class="handle top-left"></div>
              <div class="handle top-right"></div>
              <div class="handle bottom-left"></div>
              <div class="handle bottom-right"></div>
            </div>
          </div>
        </div>

        <div class="result-container">
          <h4>实时结果</h4>
          <div id="cropped-result"></div>
        </div>
      </div>
    </div>
  </body>
</html>
